extends TextureRect
@onready var popup: Popup = $Popup
@onready var name_label: Label = $Popup/MarginContainer/VBoxContainer/NameLabel
@onready var desc_label: RichTextLabel = $Popup/MarginContainer/VBoxContainer/DescLabel

var skill:Skill
var can_selected:bool = false  # 只有轮到该角色操作时才响应鼠标点击
var on_selected:bool = false:
	set(_value):
		on_selected = _value
		print(on_selected)
		if _value==true:
			$ColorRect.show()
		else:
			$ColorRect.hide()

func _ready() -> void:
	name_label.text = skill.skill_name
	desc_label.text = skill.descriptions
	popup.position = global_position + Vector2(45,0)
	


func _on_mouse_entered() -> void:
	popup.show()


func _on_mouse_exited() -> void:
	popup.hide()


func _on_gui_input(event: InputEvent) -> void:
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
		if can_selected:
			var player = get_node("../../../")
			player.select_skill(self)
			if on_selected:
				on_selected = false
			else:
				on_selected = true
